package com.yzw.phonestoreservice.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @BelongsProject: springbootdome
 * @BelongsPackage: com.yu.springbootmybatisplus.handler
 * @Author: yanhongwei
 * @CreateTime: 2022-10-24  20:36
 * @Description: TODO.实现元对象处理器接口 注意：不要忘记添加 @Component 注解  实现数据的填充
 * @Version: 1.0
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {

//       log.info("start insert fill ....");
        this.setFieldValByName("create_time", new Date(), metaObject);
        this.setFieldValByName("update_time", new Date(), metaObject);
        this.setFieldValByName("payStatus", 0, metaObject);
//给id赋值
//        this.setFieldValByName("orderId", 1, metaObject);

        //逻辑删除字段，默认为0
//        this.setFieldValByName("deleted", 0, metaObject);
//        // 添加 乐观锁的  默认值是 1
//        this.setFieldValByName("version", 1, metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {

//        log.info("start insert fill ....");
        this.setFieldValByName("update_time", new Date(), metaObject);
    }





}
